<?php
/**
 * 昨日数据统计
 * User: chapin
 * Date: 2019-01-18
 * Time: 14:26
 */
defined('BASEPATH') OR exit('No direct script access allowed');

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;


class Welcome extends CI_Controller
{
	public $data = [];
	public $dayTakeNum;
	public $bigPlat;
	public $date_time = "";
	public $collect_data;
	public $flow_data;
	public $chitu_data;

	public function __construct()
	{
		parent::__construct();

		//统计日期
		$this->data['date_time'] = date("Y-m-d 00:00:00", strtotime("-1 day"));

		//昨日每日取数
		$this->dayTakeNum = $this->db->where('date_time = "'.$this->data['date_time'].'"')->order_by('date_time', 'desc')->get('day_take_num')->row_array();
		//昨日赤兔数据
		$chitu_data = $this->db->where('date_time = "'.$this->data['date_time'].'"')->get('chitu_data')->row_array();
		//大盘数据 拿前一天
		$this->bigPlat = $this->db->where('date_time', $this->data['date_time'])->order_by('date_time', 'desc')->get('big_plat')->row_array();
		//拿到前日汇总数据
		$this->collect_data = $this->db->where('date_time', date("Y-m-d 00:00:00",strtotime("-2 day")))->get('collect_data')->row_array();
		//拿到昨日流量数据
		$this->flow_data = $this->db->where('date_time', $this->data['date_time'])->get('flow_data')->result_array();
	}

	public function index()
	{
		//店铺日销售数据
		$this->storeDayAalesData ();
		//行业大盘数据
		$this->industryBigPlatData ();
		//店铺核心指标
		$this->storeCoreIndex ();
		//货品流动指标
		$this->goodsFlowIndex ();
		//客户行为指标
		$this->customerBehaviorIndex ();
		//页面质量指标
		$this->pageQualityIndex ();
		//免费流量指标
		$this->freeTrafficIndex ();
		//自主流量指标
		$this->independentTrafficIndex ();
		//付费流量指标
		$this->payTrafficIndex ();
		//流量比例情况
		$this->flowRatioCase ();
		//dsr评分指标
		$this->dsrGradeIndex ();
		//客户服务指标
		$this->clientServiceIndex ();

		/*
		 * 行业大盘数据
		 */
		//自身收藏比
		$this->data['oneself_collect'] = empty($this->data['store_uv']) ? "" : round(($this->data['collect_buy'] / $this->data['store_uv']) * 100, 2) . "%";
		//自身加购比
		$this->data['onself_plus'] = empty($this->data['store_uv']) ? "" : round(($this->data['plus_buy'] / $this->data['store_uv']) * 100, 2) ."%";
		//自身搜索趋势
		$this->data['onself_search_trend'] = empty($this->flow_data['shoutao_search']) ? "" : round((($this->data['shoutao_search'] - $this->flow_data['shoutao_search']) / $this->flow_data['shoutao_search']) * 100, 2) . "%";

		/*
		 * 货品流动指标
		 */
		//正价货品销售金额占比
		$this->data['price_sale_proportion'] = empty($this->data['sales']) ? "" : round(($this->data['price_item_sale'] / $this->data['sales'])*100)."%";
		//特价货品销售金额占比
		$this->data['on_sale_sale_proportion'] = empty($this->data['sales']) ? "" : round(($this->data['on_sale_volume'] / $this->data['sales']) * 100, 2) . "%";

		/*
		 * 客户行为指标
		 */
		//收藏加购转化
		$this->data['collect_plus_conversion'] = empty(($this->data['plus_num'] + $this->data['collect_num'])) ? "" : round(($this->data['done_num'] / ($this->data['plus_num'] + $this->data['collect_num'])) * 100, 2) . "%";
		//加购比(人)
		$this->data['plus_rate'] = empty($this->data['store_uv']) ? "" : round(($this->data['plus_buy'] / $this->data['store_uv']) * 100, 2) . "%";
		//加购成本
		$this->data['plus_cost'] = empty($this->data['plus_buy']) ? "" : round($this->data['total_consume'] / $this->data['plus_buy'], 2);
		//收藏比(人)
		$this->data['collect_rate'] = empty($this->data['store_uv']) ? "" : round(($this->data['collect_buy'] / $this->data['store_uv']) * 100, 2)."%";
		//收藏成本
		$this->data['collect_cost'] = empty($this->data['collect_buy']) ? "" : round($this->data['total_consume'] / $this->data['collect_buy'], 2);

		/*
		 * 页面质量指标
		 */
		//店铺件数转化率
		$this->data['store_conversion'] = empty($this->data['store_uv']) ? "" : round(($this->data['done_num'] / $this->data['store_uv']) * 100,2);

		/*
		 * 免费流量指标
		 */
		//搜索占比全店流量
		$this->data['search_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round(($this->data['shoutao_search'] / $this->data['store_uv'])*100,2);
		//免费占比全店流量
		$this->data['free_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round(($this->data['shoutao_free_other'] / $this->data['store_uv'])*100,2);
		//手淘占比全店流量
		$this->data['shoutao_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round(($this->data['shoutao_home'] / $this->data['store_uv'])*100,2);
		//总占比全店流量
		$this->data['total_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round((($this->data['shoutao_search'] + $this->data['shoutao_free_other'] + $this->data['shoutao_home']) / $this->data['store_uv'])*100, 2);

		/*
		 * 自主流量指标
		 */
		//购物车占比全店流量
		$this->data['shopping_trolley_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round (($this->data['shopping_trolley'] / $this->data['store_uv'])*100, 2)."%";
		//占比全店流量
		$this->data['my_taobao_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round (($this->data['my_taobao'] / $this->data['store_uv'])*100, 2)."%";
		//总占比全店流量
		$this->data['my_taobao_total_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round((($this->data['shopping_trolley'] + $this->data['my_taobao']) / $this->data['store_uv'])*100)."%";

		/*
		 * 付费流量指标
		 */
		//花费占比销售额
		$this->data['consume_ratio_sales'] = empty($this->data['sales']) ? "" : round(($this->data['total_consume'] / $this->data['sales'])*100, 2)."%";
		//花费占比预回款
		$this->data['consume_ratio_advances_on_sales'] = empty($this->data['ready_return_amt']) ? "" : round (($this->data['total_consume'] / $this->data['ready_return_amt'])*100, 2)."%";
		//付费流量占比全店流量
		$this->data['pay_flow_ratio_store_flow'] = empty($this->data['store_uv']) ? "" : round((($this->data['through_train'] + $this->data['zhizuan']) / $this->data['store_uv'])*100, 2)."%";

		/*
		 * 客户服务指标
		 */
		//退款率
		$this->data['refund_rate'] = empty($this->data['sales']) ? "" : $this->data['refund_amt'] / $this->data['sales'];

		//活动情况
		$this->data['activity_status'] = "无";

		$result = $this->db->where('date_time', $this->data['date_time'])->get('collect_data')->row_array();

		if (empty($result)) {
			$info = $this->db->insert('collect_data', $this->data);

		} else {
			$info = $this->db->where('date_time', $this->data['date_time'])->update('collect_data', $this->data);
		}
		var_dump ($info);
	}

	//店铺日销售数据
	public function storeDayAalesData ()
	{
		//销售额
		$this->data['sales'] = empty($this->dayTakeNum['pay_amt']) ? "" : $this->dayTakeNum['pay_amt'];
		//预回款金额
		$this->data['ready_return_amt'] = empty($this->dayTakeNum['pay_amt']) ? "" : $this->dayTakeNum['pay_amt'] - $this->dayTakeNum['succe_refun_amt'];
		//销售额对比昨日
		$this->data['sale_contrast_yesterday'] = empty($this->collect_data['sales']) ? "" : ($this->data['sales'] - $this->collect_data['sales']) / $this->collect_data['sales'];
		//正价货品销售额
		$o_pay_amt = $this->db->select_sum('pay_amt')->where('date_time', $this->data['date_time'])->where('positive_price', "正价")->get('item_effect')->row_array();
		$this->data['price_item_sale'] = empty($o_pay_amt['pay_amt']) ? "" : round($o_pay_amt['pay_amt']);
		//正价货品折扣率
		$o_tag_amt = $this->db->select_sum('tag_amt')->where('date_time', $this->data['date_time'])->where('positive_price', "正价")->get('item_effect')->row_array();
		$this->data['price_discount'] = empty($o_tag_amt['tag_amt']) ? "" : round($this->data['price_item_sale'] / $o_tag_amt['tag_amt'])."%";
		//特价货品销售额
		$s_pay_amt = $this->db->select_sum('pay_amt')->where('date_time', $this->data['date_time'])->where('positive_price', "特价")->get('item_effect')->row_array();
		$this->data['on_sale_volume'] = empty($s_pay_amt['pay_amt']) ? "" : round($s_pay_amt['pay_amt']);
		//特价货品折扣率
		$s_tag_amt = $this->db->select_sum('tag_amt')->where('date_time', $this->data['date_time'])->where('positive_price', "特价")->get('item_effect')->row_array();
		$this->data['on_sale_discount'] = empty($s_tag_amt['tag_amt']) ? "" : round($this->data['special_sales_goods'] / $s_tag_amt['tag_amt'])."%";
	}

	//行业大盘数据
	public function industryBigPlatData ()
	{
		//大盘访客数
		$this->data['market_visitors'] = empty($this->bigPlat['visitor']) ? "" : $this->bigPlat['visitor'];
		//对比昨日升降
		$this->data['compare_yesterday_rising_lowering'] = empty($this->collect_data['market_visitors']) ? "" : ($this->data['market_visitors'] - $this->collect_data['market_visitors']) / $this->collect_data['market_visitors'];
		//大盘收藏比
		$this->data['market_collect'] = empty($this->bigPlat['visitor']) ? "" : sprintf("%01.2f",($this->bigPlat['collect_peo_num'] / $this->bigPlat['visitor']) * 100) . "%";
		//大盘加购比
		$this->data['market_plus'] = empty($this->bigPlat['visitor']) ? "" : sprintf("%01.2f", ($this->bigPlat['add_purcha_peo_num'] / $this->bigPlat['visitor']) * 100) . "%";
	}

	//店铺核心指标
	public function storeCoreIndex ()
	{
		//全店uv
		$this->data['store_uv'] = empty($this->dayTakeNum['visitor']) ? "" : $this->dayTakeNum['visitor'];
		//客单价
		$this->data['customer_price'] = empty($this->dayTakeNum['custo_price']) ? "" : $this->dayTakeNum['custo_price'];
		//转化率
		$this->data['conversion'] = empty($this->dayTakeNum['pay_conver_rate']) ? "" : $this->dayTakeNum['pay_conver_rate'];
		//UV价值
		$this->data['uv_value'] = empty($this->data['conversion']) ? "" : round($this->data['customer_price'] * ($this->data['conversion'] / 100), 2);
		//流量对比昨日
		$this->data['flow_contrast_yesterday'] = empty($this->collect_data['store_uv']) ? "" : ($this->data['store_uv'] - $this->collect_data['store_uv']) / $this->collect_data['store_uv'];
		//转化对比昨日
		$this->data['conversion_contrast_yesterday'] = empty($this->collect_data['conversion']) ? "" : ($this->data['conversion'] - $this->collect_data['conversion']) / $this->collect_data['conversion'];
	}

	//货品流动指标
	public function goodsFlowIndex ()
	{
		//支付商品数
		$this->data['pay_item'] = empty($this->dayTakeNum['pay_item_num']) ? "" : $this->dayTakeNum['pay_item_num'];
		//全店宝贝数
		$goods_num = $this->db->where('date_time', $this->data['date_time'])->from('item_stock')->count_all_results();
		$this->data['store_item'] = empty($goods_num) ? "" : $goods_num;
		//动销率
		$this->data['rate_of_pin'] = empty($this->data['store_item']) ? "" : round(($this->data['pay_item'] / $this->data['store_item']) * 100, 2) . "%";
		//消化率
		$effect_original = $this->db->select_sum('pay_item_num')->where("date_time", $this->data['date_time'])->where('positive_price', "正价")->get('item_effect')->row_array();
		$effect_special = $this->db->select_sum('pay_item_num')->where("date_time", $this->data['date_time'])->where('positive_price', "特价")->get('item_effect')->row_array();
		$effect = $effect_original['pay_item_num'] + $effect_special['pay_item_num'];
		$stock_original = $this->db->select_sum('item_stock')->where("date_time", $this->data['date_time'])->where('positive_price', "正价")->get('item_stock')->row_array();
		$stock_special = $this->db->select_sum('item_stock')->where("date_time", $this->data['date_time'])->where('positive_price', "特价")->get('item_stock')->row_array();
		$stock = $stock_original['item_stock'] + $stock_special['item_stock'];
		$this->data['digestibility'] = empty($stock) || empty($effect) ? "" : round(($effect / $stock) * 100, 2) ."%";
		//正价货品支付商品数
		$effect_goods = $this->db->where('date_time', $this->data['date_time'])->where('positive_price', "正价")->where('pay_item_num >= 1')->from('item_effect')->count_all_results();
		$this->data['price_pay_item'] = empty($effect_goods) ? "" : $effect_goods;
		//正价货品上架数
		$effect_shelves = $this->db->where('date_time', $this->data['date_time'])->where('positive_price', "正价")->from('item_effect')->count_all_results();
		$this->data['price_item_putaway'] = empty($effect_shelves) ? "" : $effect_shelves;
		//正价货品动销率
		$this->data['price_rate_of_pin'] = empty($this->data['price_item_putaway']) ? "" : round(($this->data['price_pay_item'] / $this->data['price_item_putaway']) * 100 , 2)."%";
		//正价货品消化率
		$this->data['price_digestibility'] = empty($stock_original['item_stock']) ? "" : round(($effect_original['pay_item_num'] / $stock_original['item_stock']) * 100, 2) . "%";
		//特价货品支付商品数
		$effect_goods_special = $this->db->where('date_time', $this->data['date_time'])->where('positive_price', "特价")->where('pay_item_num >= 1')->from('item_effect')->count_all_results();
		$this->data['on_sale_pay_item'] = empty($effect_goods_special) ? "" : $effect_goods_special;
		//特价货品上架数
		$effect_shelves_special = $this->db->where('date_time', $this->data['date_time'])->where('positive_price', "特价")->from('item_effect')->count_all_results();
		$this->data['on_sale_item_putaway'] = empty($effect_shelves_special) ? "" : $effect_shelves_special;
		//特价货品动销率
		$this->data['on_sale_rate_of_pin'] = empty($this->data['on_sale_item_putaway']) ? "" : round(($this->data['on_sale_pay_item'] / $this->data['on_sale_item_putaway']) * 100, 2) ."%";
		//特价货品消化率
		$this->data['on_sale_digestibility'] = empty($stock_special['item_stock']) ? "" : round(($effect_special['pay_item_num'] / $stock_special['item_stock']) * 100, 2) . "%";
	}

	//客户行为指标
	public function customerBehaviorIndex ()
	{
		//成交件数
		$effect_original = $this->db->select_sum('pay_item_num')->where("date_time", $this->data['date_time'])->where('positive_price', "正价")->get('item_effect')->row_array();
		$effect_special = $this->db->select_sum('pay_item_num')->where("date_time", $this->data['date_time'])->where('positive_price', "特价")->get('item_effect')->row_array();
		$effect = $effect_original['pay_item_num'] + $effect_special['pay_item_num'];
		$this->data['done_num'] = empty($effect) ? "" : $effect;
		//成交人数
		$this->data['done_buy'] = empty($this->dayTakeNum['pay_buy_num']) ? "" : $this->dayTakeNum['pay_buy_num'];
		//人均件数
		$this->data['per_capita_num'] = empty($this->data['done_buy']) ? "" : $this->data['done_num'] / $this->data['done_buy'];
		//加购(件)
		$this->data['plus_num'] = empty($this->dayTakeNum['add_purcha_num']) ? "" : $this->dayTakeNum['add_purcha_num'];
		//加购(人)
		$this->data['plus_buy'] = empty($this->dayTakeNum['add_purcha_peo_num']) ? "" : $this->dayTakeNum['add_purcha_peo_num'];
		//收藏件数
		$this->data['collect_num'] = empty($this->dayTakeNum['collect_num']) ? "" : $this->dayTakeNum['collect_num'];
		//收藏人数
		$this->data['collect_buy'] = empty($this->dayTakeNum['collect_buy_num']) ? "" : $this->dayTakeNum['collect_buy_num'];
		//店铺收藏人数
		$this->data['store_collect_buy'] = empty($this->dayTakeNum['shop_collect_buy_num']) ? "" : $this->dayTakeNum['shop_collect_buy_num'];
	}

	//页面质量指标
	public function pageQualityIndex()
	{
		//跳失率
		$this->data['miss_rate'] = empty($this->dayTakeNum['jump_leave_rate']) ? "" : $this->dayTakeNum['jump_leave_rate'];
		//停留时长
		$this->data['stay_time'] = empty($this->dayTakeNum['aver_leng_of_stay']) ? "" : $this->dayTakeNum['aver_leng_of_stay'];
		//全店PV
		$this->data['store_pv'] = empty($this->dayTakeNum['pageviews']) ? "" : $this->dayTakeNum['pageviews'];
		//人均访问深度
		$this->data['per_capita_visit_depth'] = empty($this->dayTakeNum['per_capit_pageviews']) ? "" : $this->dayTakeNum['per_capit_pageviews'];
	}


	//免费流量指标
	public function freeTrafficIndex()
	{
		//手淘搜索
		$shoutao_search = $this->db->where('date_time', $this->data['date_time'])->where('source_detail', '手淘搜索')->get('flow_data')->row_array();
		$this->data['shoutao_search'] = empty($shoutao_search['visitors']) ? "" : $shoutao_search['visitors'];
		//手淘搜索转化率
		$this->data['shoutao_search_conversion'] = empty($shoutao_search['pay_conversion']) ? "" : $shoutao_search['pay_conversion'];
		//淘内免费其他
		$taonei_free = $this->db->where('date_time', $this->data['date_time'])->where('source_detail', '淘内免费其他')->get('flow_data')->row_array();
		$this->data['shoutao_free_other'] = empty($taonei_free['visitors']) ? "" : $taonei_free['visitors'];
		//免费其他转化率
		$this->data['free_other_conversion'] = empty($taonei_free['pay_conversion']) ? "" : $taonei_free['pay_conversion'];
		//手淘首页
		$shoutao_home = $this->db->where('date_time', $this->data['date_time'])->where('source_detail', '手淘首页')->get('flow_data')->row_array();
		$this->data['shoutao_home'] = empty($shoutao_home['visitors']) ? "" : $shoutao_home['visitors'];
		//手淘首页转化率
		$this->data['shoutao_home_conversion'] = empty($shoutao_home['pay_conversion']) ? "" : $shoutao_home['pay_conversion'];
	}

	//自主流量指标
	public function independentTrafficIndex()
	{
		//购物车
		$shopping_trolley = $this->db->where('date_time', $this->data['date_time'])->where('source_detail', '购物车')->get('flow_data')->row_array();
		$this->data['shopping_trolley'] = empty($shopping_trolley['visitors']) ? "" : $shopping_trolley['visitors'];
		//购物车转化率
		$this->data['shopping_trolley_conversion'] = empty($shopping_trolley['pay_conversion']) ? "" : $shopping_trolley['pay_conversion'];
		//我的淘宝
		$my_taobao = $this->db->where('date_time', $this->data['date_time'])->where('source_detail', '我的淘宝')->get('flow_data')->row_array();
		$this->data['my_taobao'] = empty($my_taobao['visitors']) ? "" : $my_taobao['visitors'];
		//我的淘宝转化率
		$this->data['my_taobao_conversion'] = empty($my_taobao['pay_conversion']) ? "" : $my_taobao['pay_conversion'];
	}

	//付费流量指标
	public function payTrafficIndex()
	{
		//直通车花费
		$this->data['through_train_consume'] = empty($this->dayTakeNum['throu_train_pay']) ? "" : $this->dayTakeNum['throu_train_pay'];
		//直通车
		$through_train = $this->db->where('date_time', $this->data['date_time'])->where('source_detail', '直通车')->get('flow_data')->row_array();
		$this->data['through_train'] = empty($through_train['visitors']) ? "" : $through_train['visitors'];
		//直通车uv成本
		$this->data['through_train_uv_cost'] = empty($this->data['through_train']) ? "" : $this->data['through_train_consume'] / $this->data['through_train'];
		//收藏加购比例
		$this->data['through_train_collect_plus_rate'] = empty($this->data['through_train']) ? "" : round((($through_train['collect_item_buy'] + $through_train['plus_num']) / $this->data['through_train'])*100, 2) . "%";
		//收藏加购成本
		$this->data['through_train_collect_plus_cost'] = empty($through_train['collect_item_buy'] + $through_train['plus_num']) ? "" : $this->data['through_train_consume'] / ($through_train['collect_item_buy'] + $through_train['plus_num']);
		//直通车转化率
		$this->data['through_train_conversion'] = empty($through_train['pay_conversion']) ? "" : $through_train['pay_conversion'];
		//直通车成交额
		$this->data['through_train_turn_volume'] = empty($through_train['pay_amt']) ? "" : $through_train['pay_amt'];
		//直通车当日roi
		$this->data['through_train_roi'] = empty($this->data['through_train_consume']) ? "" : $this->data['through_train_turn_volume'] / $this->data['through_train_consume'];
		//钻展花费
		$this->data['CPM_consume'] = empty($this->dayTakeNum['drill_exhib_pay']) ? "" : $this->dayTakeNum['drill_exhib_pay'];
		//智钻
		$zhizuan = $this->db->where('date_time', $this->data['date_time'])->where('source_detail', '智钻')->get('flow_data')->row_array();
		$this->data['zhizuan'] = empty($zhizuan['visitors']) ? "" : $zhizuan['visitors'];
		//钻展uv成本
		$this->data['CPM_uv_cost'] = empty($this->data['zhizuan']) ? "" : round($this->data['CPM_consume'] / $this->data['zhizuan'], 2);
		//收藏加购比例
		$this->data['CPM_collect_plus_rate'] = empty($this->data['zhizuan']) ? "" : round((($zhizuan['collect_item_buy'] + $zhizuan['plus_num']) / $this->data['zhizuan'])*100, 2) . "%";
		//收藏加购成本
		$this->data['CPM_collect_plus_cost'] = empty($zhizuan['collect_item_buy'] + $zhizuan['plus_num']) ? "" : round ($this->data['CPM_consume'] / ($zhizuan['collect_item_buy'] + $zhizuan['plus_num']));
		//钻展转化率
		$this->data['CPM_conversion'] = empty($zhizuan['pay_conversion']) ? "" : $zhizuan['pay_conversion'];
		//钻展成交额
		$this->data['CPM_turn_volume'] = empty($zhizuan['pay_amt']) ? "" : $zhizuan['pay_amt'];
		//钻展当日roi
		$this->data['CPM_roi'] = empty($this->data['CPM_consume']) ? "" : round($this->data['CPM_turn_volume'] / $this->data['CPM_consume'],2);
		//总花费（含品销宝、淘客）
		$this->data['total_consume'] = empty($this->dayTakeNum['tot_pay']) ? "" : $this->dayTakeNum['tot_pay'];
	}

	//流量比例情况
	public function flowRatioCase()
	{
		//新访客
		$this->data['new_visitor'] = empty($this->data['old_visitor']) ? "" : round((1- ($this->dayTakeNum['old_visitor'] / ($this->dayTakeNum['old_visitor'] + $this->dayTakeNum['new_visitor']))) * 100, 2) . "%";
		//老访客
		$this->data['old_visitor'] = empty(($this->dayTakeNum['old_visitor'] + $this->dayTakeNum['new_visitor'])) ? "" : round(($this->dayTakeNum['old_visitor'] / ($this->dayTakeNum['old_visitor'] + $this->dayTakeNum['new_visitor'])) * 100, 2) . "%";
	}

	//dsr评分指标
	public function dsrGradeIndex()
	{
		//描述
		$this->data['describe'] = empty($this->dayTakeNum['desc_match_score']) ? "" : $this->dayTakeNum['desc_match_score'];
		//描述较同行
		$this->data['desc_contrast_peer'] = empty($this->dayTakeNum['desc_same_aver']) ? "" : $this->dayTakeNum['desc_same_aver'];
		//服务
		$this->data['service'] = empty($this->dayTakeNum['service_atti_score']) ? "" : $this->dayTakeNum['service_atti_score'];
		//服务较同行
		$this->data['service_contrast_peer'] = empty($this->dayTakeNum['service_same_aver']) ? "" : $this->dayTakeNum['service_same_aver'];
		//物流
		$this->data['logistics'] = empty($this->dayTakeNum['logist_services_score']) ? "" : $this->dayTakeNum['logist_services_score'];
		//物流较同行
		$this->data['logistics_contrast_peer'] = empty($this->dayTakeNum['logistic_same_aver']) ? "" : $this->dayTakeNum['logistic_same_aver'];
		//dsr负面评价数
		$this->data['dsr_negative_appraise'] = empty($this->dayTakeNum['negat_commen_num']) ? "" : $this->dayTakeNum['negat_commen_num'];
	}

	//客户服务指标
	public function clientServiceIndex()
	{
		//退款笔数
		$refund_num = $this->db->select_sum('afte_sale_succe_refun_amt')->where('date_time', $this->data['date_time'])->get('item_effect')->row_array();
		$this->data['refund_num'] = empty($refund_num['afte_sale_succe_refun_amt']) ? "" : $refund_num['afte_sale_succe_refun_amt'];
		//退款金额
		$this->data['refund_amt'] = empty($this->dayTakeNum['succe_refun_amt']) ? "" : $this->dayTakeNum['succe_refun_amt'];
		//客服咨询量
		$this->data['customer_service_consultation'] = empty($this->chitu_data['advisory_peo_num']) ? "" : $this->chitu_data['advisory_peo_num'];
		//客服销售额
		$this->data['customer_service_sale'] = empty($this->chitu_data['cust_service_sale_pay']) ? "" : $this->chitu_data['cust_service_sale_pay'];
		//客服成功率
		$this->data['customer_service_success'] = empty($this->chitu_data['tomorrow_pay_succe_rate']) ? "" : $this->chitu_data['tomorrow_pay_succe_rate'];
		//客服回复率
		$this->data['customer_service_reversion_rate'] = empty($this->chitu_data['wangwang_reply_rate']) ? "" : $this->chitu_data['wangwang_reply_rate'];
		//平均响应时间
		$this->data['avg_respond_time'] = empty($this->chitu_data['aver_response_time']) ? "" : $this->chitu_data['aver_response_time'];
		//慢响应人数
		$this->data['slow_respond_num'] = empty($this->chitu_data['slow_response_peo_num']) ? "" : $this->chitu_data['slow_response_peo_num'];
		//长接待人数
		$this->data['long_reception_num'] = empty($this->chitu_data['long_receptio_peo_num']) ? "" : $this->chitu_data['long_receptio_peo_num'];
	}


}
